﻿//更新点击数，差评，好评
function updateArticleNum(id, moduleType, cmd)
    {

        $.ajax({
            type: "get",
            dataType: "json",
            data: "time="+(new Date().getTime()),
            url: "/" + id + "/" + moduleType + "/" + cmd,
            error: function (XmlHttpRequest, textStatus, errorThrown) { alert(errorThrown); alert(textStatus); alert(XmlHttpRequest.responseText); },
            success: function (d) {
                switch (d.result) {
                    case '0':
                        alert("提交失败");
                        break;
                    case '1':
                        if (cmd == "upsupport") {
                            var num = 0;
                            num = $("#digg_num").html()
                            num = parseInt(num) + 1;
                            $("#digg_num").html(num);
                            $("#digg_tip").html("推荐成功");
                            $("#diggit").bind("click", function () { void (0); });

                        }
                        else if (cmd == "upagainst") {
                            var num = 0;

                            num = $("#bury_num").html()
                            num = parseInt(num) + 1;
                            $("#bury_num").html(num);
                            $("#digg_tip").html("反对成功");
                            $("#buryit").bind("click", function () { void (0); });
                        }

                        break;

                    case "-1":
                        alert(d.returnval);
                        break;
                }
            }
        });
}

function ajaxPluginVoteAdd(id, mtype, btn) {
    btn = "#" + btn;
    $(btn).attr("disabled", "disabled");
    var voteNum;
    var rbVote = $("#voteform input");
    for (var i = 0; i < rbVote.length; i++) {
        if (rbVote[i].checked && (rbVote[i].type == "radio" || rbVote[i].type == "checkbox")) {
            if (!voteNum)
                voteNum = rbVote[i].value;
            else
                voteNum += "," + rbVote[i].value;
        }
    }
    if (!voteNum) {
        alert("请先选择一项!");
        $(btn).attr("disabled", "");
        return;
    }
    $.ajax({
        type: "get",
        dataType: "html",
        data: "id=" + id + "&mtype=" + mtype + "&vote=" + voteNum + "&time=" + (new Date().getTime()),
        url: site.Dir + "extends/vote/ajax.aspx?oper=ajaxPluginVoteAdd",
        error: function (XmlHttpRequest, textStatus, errorThrown) { if (XmlHttpRequest.responseText != "") { alert(XmlHttpRequest.responseText); } },
        success: function (d) {
            if (d == "ok") {
                alert("成功,谢谢你的投票!");
            }
            else {
                alert(d);
                $(btn).attr("disabled", "");
            }
        }
    });
}


